<script setup lang="ts">
import * as echarts from 'echarts'
const charts = ref()
onMounted(() => {
  let myecharts = echarts.init(charts.value)
  // 设置echarts配置项
  myecharts.setOption({
    // 标题组件
    // title: {
    //   text: '水球图',
    //   textStyle: {
    //     color: 'skyblue' // 标题颜色
    //   },
    //   left: '40%' // 标题位置
    // },
    // x|y轴组件
    xAxis: {
      show: false, // 不显示
      // type: 'category', // x均匀分布
      min: 0, // 最大小值
      max: 100
    },
    yAxis: {
      show: false,
      type: 'category' // y均匀分布
    },
    // 数据系列
    series: [
      {
        type: 'bar',
        data: [58],
        barWidth: 20, // 图条宽度
        z: 10, // 层级 默认2
        itemStyle: {
          borderRadius: [10, 0, 0, 10] // 图条圆角
        }
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        barGap: '-100%', // 改变图条的位置
        itemStyle: {
          color: 'pink',
          borderRadius: 10 // 图条圆角
        }
      }
    ],
    // 位置布局
    grid: {
      left: 10,
      right: 10,
      top: 5,
      bottom: 10
    }
  })
})
</script>

<template>
  <div class="box1">
    <div class="top">
      <p class="title">男女比例</p>
      <p class="bg"></p>
    </div>
    <div class="sex">
      <div class="man">
        <img src="../images/man.png" alt="" />
      </div>
      <div class="woman">
        <img src="../images/woman.png" alt="" />
      </div>
    </div>
    <div class="rate">
      <p>男士 58%</p>
      <p>女士 42%</p>
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<style lang="scss" scoped>
.box1 {
  width: 100%;
  height: 100%;
  background: url(../images/dataScreen-main-lb.png) no-repeat;
  background-size: 100% 100%;
  margin-top: 10px;
  .top {
    margin: 10px 0 0 20px;
    .title {
      color: white;
      font-size: 20px;
    }
    .bg {
      width: 100px;
      height: 7px;
      background: url(../images/dataScreen-title.png) no-repeat;
      background-size: 100% 100%;
      margin-top: 10px;
    }
  }
  .sex {
    display: flex;
    justify-content: center;
    .man {
      width: 111px;
      height: 115px;
      margin: 20px;
      background: url(../images/man-bg.png) no-repeat;
      background-size: 100% 100%;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .woman {
      width: 111px;
      height: 115px;
      margin: 20px;
      background: url(../images/woman-bg.png) no-repeat;
      background-size: 100% 100%;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
  .rate {
    display: flex;
    justify-content: space-around;
    color: white;
  }
  .charts {
    width: 100%;
    height: 70px;
  }
}
</style>
